﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>呷饭网</title>
    <link rel="stylesheet" type="text/css" href="styles/mobile.css" />
    <link href="styles/jquery.ui.all.css" rel="stylesheet" />
    <script type="text/javascript" src="scripts/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="scripts/jquery.bgiframe-2.1.1.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.core.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.mouse.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.button.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.draggable.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.position.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.dialog.js"></script>
    <link href="styles/flexy-menu.css" rel="stylesheet" />
    <script type="text/javascript" src="scripts/flexy-menu.js"></script>
    <script type="text/javascript" src="scripts/common.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $(".flexy-menu").flexymenu({ speed: 100 });
            $('.goback').click(function () {
                //window.history.back();
                window.location.href = "./login.html";
            });

            $('.menulink').click(function () {
                if ($(this).hasClass("actived")) {
                    $(this).children('a').children('b').text('∨');
                    $(this).removeClass('actived');
                    $('.tbllist').removeClass('tbllistbg');
                }
                else {
                    $(this).siblings('td').children('a').children('b').text('∨');
                    $(this).children('a').children('b').text('∧');
                    $(this).siblings('td').removeClass('actived');
                    $(this).addClass('actived');
                    $('.tbllist').addClass('tbllistbg');
                }
            });

        });

        $(function () {
            getUserInfo();
            getOrderList("Today");
        });      

        //根据时间获取订单数据
        function getOrderList(flag) {
            $("#tbllist").html("");

            if (flag == "Today") {
                $("#tabOne").text("今天");
            }
            else if (flag == "Tomorrow") {
                $("#tabOne").text("明天");
            }
            else if (flag == "Postnatal") {
                $("#tabOne").text("后天");
            }
            else if (flag == "OtherTime") {
                $("#tabOne").text("其他时间");
            }
            $("#tabTwo").text("类型");
            $("#tabThree").text("操作");
            
            var datas = "&flag=" + flag;
            var url = "CommonPage.aspx?opration=getOrderList" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    $("#Today").text(data.Today);
                    $("#Tomorrow").text(data.Tomorrow);
                    $("#Postnatal").text(data.Postnatal);
                    if (data.Success) {
                        $("#Total").text(data.Total);
                        $(".tips")[0].style.display = "none";
                        for (var i = 0, str = ''; i < data.List.length; i++) {
                            var ContactMobile = "无号码";
                            if (data.List[i].ContactMobile != "") {
                                ContactMobile = data.List[i].ContactMobile;
                            }
                            var H_Name = encodeURIComponent($("#H_Name")[0].innerHTML);
                            if (data.List[i].OrderState == "tbldetail") {
                                str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c'><b>" + data.List[i].ContactUser + "</b>(" + ContactMobile + ")<br/>" + data.List[i].Reserve + "</td><td class='r' style='vertical-align:middle'><a href='tbldetail.html?PageFlag=1&HotelId=" + data.HotelId + "&OrderId=" + data.List[i].Id + "&Name=" + encodeURIComponent(data.List[i].Name) + "&H_Name=" + H_Name + "'>操作</a></td></tr>";
                            }
                            else if (data.List[i].OrderState == "tbldetails") {
                                str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c'><b>" + data.List[i].ContactUser + "</b>(" + ContactMobile + ")<br/>" + data.List[i].Reserve + "</td><td class='r' style='vertical-align:middle'><a href='tbldetails.html?PageFlag=1&HotelId=" + data.HotelId + "&OrderId=" + data.List[i].Id + "&Name=" + encodeURIComponent(data.List[i].Name) + "&H_Name=" + H_Name + "' class='btn2'>查看</a></td></tr>";
                            }
                        }
                        $("#tbllist").html(str);
                    }
                    else {
                        if (data.Url != "") {
                            updateTip(data.Msg, true, "URL", data.Url);
                        }
                        else {
                            $("#Total").text("0");
                            $(".tips")[0].style.display = "";
                            $("#msgtip").text(data.Msg);
                        }
                    }
                }
            });
        }
        function getOrderLists(flag)
        {
            var datas = "&flag=" + flag;
            var url = "CommonPage.aspx?opration=getOrderList" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    if (data.Success) {
                        $("#Today").text(data.Today);
                        $("#Tomorrow").text(data.Tomorrow);
                        $("#Postnatal").text(data.Postnatal);
                    }
                    else {
                        if (data.Url != "") {
                            updateTip(data.Msg, true, "URL", data.Url);
                        }
                    }
                }
            });
        }

        //根据类型获取订单数据
        function getTableType(flag) {
            $("#tbllist").html("");
            if (flag == "All") {
                $("#tabTwo").text("全部");
            }
            else if (flag == "Rooms") {
                $("#tabTwo").text("包间");
            }
            else if (flag == "Hall") {
                $("#tabTwo").text("大厅");
            }
            else if (flag == "AddTable") {
                $("#tabTwo").text("加台");
            }
            $("#tabOne").text("今天");
            $("#tabThree").text("操作");

            var datas = "&flag=" + flag;
            var url = "CommonPage.aspx?opration=getTableType" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    $("#All").text("(" + data.All + ")");
                    $("#Rooms").text("(" + data.Rooms + ")");
                    $("#Hall").text("(" + data.Hall + ")");
                    $("#AddTable").text("(" + data.AddTable + ")");
                    if (data.Success) {
                        $("#Total").text(data.Total);
                        $(".tips")[0].style.display = "none";
                        for (var i = 0, str = ''; i < data.List.length; i++) {
                            var ContactMobile = "无号码";
                            if (data.List[i].ContactMobile != "") {
                                ContactMobile = data.List[i].ContactMobile;
                            }
                            if (data.List[i].OrderId == "") {
                                str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c' style='vertical-align:middle'>可坐人数：" + data.List[i].Numbers + "人</td><td class='r' style='vertical-align:middle'><a href='#' name='" + data.List[i].Name + "' dir='" + data.List[i].Category + "' onclick='openDineTable(this," + data.List[i].HotelId + "," + data.List[i].SeatId + ",\"manager.html\",1);'>开台</a></td></tr>";
                            }
                            else {
                                var H_Name = encodeURIComponent($("#H_Name")[0].innerHTML);
                                if (data.List[i].OrderState == "tbldetail") {
                                    str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c'><b>" + data.List[i].ContactUser + "</b>(" + ContactMobile + ")<br/>" + data.List[i].Reserve + "</td><td class='r' style='vertical-align:middle'><a href='tbldetail.html?PageFlag=1&OrderId=" + data.List[i].OrderId + "&Name=" + encodeURIComponent(data.List[i].Name) + "&H_Name=" + H_Name + "'>操作</a></td></tr>";
                                }
                                else if (data.List[i].OrderState == "tbldetails") {
                                    str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c'><b>" + data.List[i].ContactUser + "</b>(" + ContactMobile + ")<br/>" + data.List[i].Reserve + "</td><td class='r' style='vertical-align:middle'><a href='tbldetails.html?PageFlag=1&OrderId=" + data.List[i].OrderId + "&Name=" + encodeURIComponent(data.List[i].Name) + "&H_Name=" + H_Name + "' class='btn2'>查看</a></td></tr>";
                                }
                            }
                        }
                        $("#tbllist").html(str);
                    }
                    else {
                        if (data.Url != "") {
                            updateTip(data.Msg, true, "URL", data.Url);
                        }
                        else {
                            $("#Total").text("0");
                            $(".tips")[0].style.display = "";
                            $("#msgtip").text(data.Msg);
                        }
                    }
                }
            });
        }
        function getTableTypes(flag) {
            var datas = "&flag=" + flag;
            var url = "CommonPage.aspx?opration=getTableType" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    if (data.Success) {
                        $("#All").text("(" + data.All + ")");
                        $("#Rooms").text("(" + data.Rooms + ")");
                        $("#Hall").text("(" + data.Hall + ")");
                        $("#AddTable").text("(" + data.AddTable + ")");
                    }
                    else {
                        if (data.Url != "") {
                            updateTip(data.Msg, true, "URL", data.Url);
                        }
                    }
                }
            });
        }

        //根据操作获取订单数据
        function getHandleType(flag) {
            $("#tbllist").html("");
           /* if (flag == "Seated") {
                $("#tabThree").text("就坐");
            }
            else if (flag == "OpenTable") {
                $("#tabThree").text("开台");
            }
            else if (flag == "CheckOut") {
                $("#tabThree").text("结账");
            }*/
            /*
            */ 
            if (flag == "Clear") {
                $("#tabThree").text("正在清理");
            }
            else if (flag == "OpenTable") {
                $("#tabThree").text("欢迎光临");
            }
            else if (flag == "Seated") {
                $("#tabThree").text("正在点菜");
            }
            else if (flag == "CheckOut") {
                $("#tabThree").text("正在用餐");
            }
            else if (flag == "Scheduled") {
                $("#tabThree").text("已被预订");
            }
            
           
         
            $("#tabOne").text("今天");
            $("#tabTwo").text("类型");

            var datas = "&flag=" + flag;
            var url = "CommonPage.aspx?opration=getHandleType" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    $("#Seated").text(data.Seated);
                    $("#OpenTable").text(data.OpenTable);
                    $("#CheckOut").text(data.CheckOut);
                    $("#Scheduled").text(data.Scheduled);
                    $("#Clear").text(data.Clear); 
                    if (data.Success) {
                        $("#Total").text(data.Total);
                        $(".tips")[0].style.display = "none";
                        for (var i = 0, str = ''; i < data.List.length; i++) {

                            var ContactMobile = "无号码";
                            if (data.List[i].ContactMobile != "") {
                                ContactMobile = data.List[i].ContactMobile;
                            }
                            var H_Name = encodeURIComponent($("#H_Name")[0].innerHTML);

                            if (data.List[i].Scheduled == "1") {
                                str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c'><b>" + data.List[i].ContactUser + "</b>(" + ContactMobile + ")<br/>" + data.List[i].Reserve + "</td><td class='r' style='vertical-align:middle'><a href='tbldetail.html?PageFlag=1&HotelId=" + data.List[i].HotelId + "&OrderId=" + data.List[i].OrderId + "&Name=" + data.List[i].Name + "' class='btn2'>就坐</a></td></tr>";
                            }
                            if (data.List[i].OpenTable == "1") {
                                str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c' style='vertical-align:middle'>可坐人数：" + data.List[i].Numbers + "人</td><td class='r' style='vertical-align:middle'><a href='#' name='" + data.List[i].Name + "' dir='" + data.List[i].Category + "' onclick='openDineTable(this," + data.List[i].HotelId + "," + data.List[i].SeatId + ",\"manager.html\",1);'>开台</a></td></tr>";
                            }
                            if (data.List[i].Seated == "1") {
                                str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c'><b>" + data.List[i].ContactUser + "</b>(" + ContactMobile + ")<br/>" + data.List[i].Reserve + "</td><td class='r' style='vertical-align:middle'><a href='tbldetails.html?PageFlag=1&OrderId=" + data.List[i].OrderId + "' class='btn2'>查看</a></td></tr>";
                            }
                            if (data.List[i].CheckOut == "1") {
                                str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c'><b>" + data.List[i].ContactUser + "</b>(" + ContactMobile + ")<br/>" + data.List[i].Reserve + "</td><td class='r' style='vertical-align:middle'><a href='cashier.html?PageFlag=1' class='btn2'>结账</a></td></tr>";
                            }
                            if (data.List[i].Clear == "1") {
                                str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c'><b>" + data.List[i].ContactUser + "</b>(" + ContactMobile + ")<br/>" + data.List[i].Reserve + "</td><td class='r' style='vertical-align:middle'><a href='clean.html?PageFlag=1'   class='btn2'>清台</a></td></tr>";
                            }

                            /* if (data.List[i].OrderId == "" || data.List[i].OrderId == "0") {
                                str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c' style='vertical-align:middle'>可坐人数：" + data.List[i].Numbers + "人</td><td class='r' style='vertical-align:middle'><a href='#' name='" + data.List[i].Name + "' dir='" + data.List[i].Category + "' onclick='openDineTable(this," + data.List[i].HotelId + "," + data.List[i].SeatId + ",\"manager.html\",1);'>开台</a></td></tr>";
                            }
                            else {
                                var ContactMobile = "无号码";
                                if (data.List[i].ContactMobile != "") {
                                    ContactMobile = data.List[i].ContactMobile;
                                }
                                var H_Name = encodeURIComponent($("#H_Name")[0].innerHTML);

                                if (data.List[i].OrderState == 2) {
                                    str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c'><b>" + data.List[i].ContactUser + "</b>(" + ContactMobile + ")<br/>" + data.List[i].Reserve + "</td><td class='r' style='vertical-align:middle'><a href='tbldetail.html?PageFlag=1&HotelId=" + data.List[i].HotelId + "&OrderId=" + data.List[i].OrderId + "&Name=" + data.List[i].Name + "' class='btn2'>就坐</a></td></tr>";
                                } 
                                if (data.List[i].TableState == 0 && data.List[i].OrderState == 4) {
                                   // str += "<tr><td class='l'>" + data.List[i].Name + "</td><td class='l'>" + data.List[i].Category + "</td><td class='c'>" + data.List[i].RoomNumber + "</td><td class='c'><b>￥" + data.List[i].TotalPrice + "</b></td><td class='r'><a href='#' style='width:65px;' onclick=\"OrderPaying('" + data.List[i].OrderId + "','" + data.HotelId + "','" + data.UserId + "','" + data.UserPwd + "','" + data.List[i].Token + "');\">结账</a></td></tr>";
                                    str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c'><b>" + data.List[i].ContactUser + "</b>(" + ContactMobile + ")<br/>" + data.List[i].Reserve + "</td><td class='r' style='vertical-align:middle'><a href='cashier.html?PageFlag=1' class='btn2'>结账</a></td></tr>";
                                }
                                else if (data.List[i].TableState == 1 && data.List[i].OrderState == 4) {
                                    str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c'><b>" + data.List[i].ContactUser + "</b>(" + ContactMobile + ")<br/>" + data.List[i].Reserve + "</td><td class='r' style='vertical-align:middle'><a href='tbldetails.html?PageFlag=1&OrderId=" + data.List[i].OrderId + "' class='btn2'>查看</a></td></tr>";
                                }
                                else if (data.List[i].TableState == 0 && (data.List[i].OrderState == 5 || data.List[i].OrderState == 7)) {
                                    //  str += "<tr><td class='l'>" + data.List[i].Name + "</td><td class='l'>" + data.List[i].Category + "</td><td class='c'>" + data.List[i].RoomNumber + "</td><td class='c'><b>￥" + data.List[i].TotalPrice + "</b></td><td class='r'><a href='#' style='width:65px;' onclick='cleanDineTable(" + data.List[i].OrderId + "," + data.List[i].DineTableId + ");'>清台</a></td></tr>";
                                    str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c'><b>" + data.List[i].ContactUser + "</b>(" + ContactMobile + ")<br/>" + data.List[i].Reserve + "</td><td class='r' style='vertical-align:middle'><a href='clean.html?PageFlag=1'   class='btn2'>清台</a></td></tr>";
                                } /*else {
                                    str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c'><b>" + data.List[i].ContactUser + "</b>(" + ContactMobile + ")<br/>" + data.List[i].Reserve + "</td><td class='r' style='vertical-align:middle'><a href='tbldetails.html?PageFlag=1&OrderId=" + data.List[i].OrderId + "' class='btn2'>查看</a></td></tr>";
                                }#1# 
                                // str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c'><b>" + data.List[i].ContactUser + "</b>(" + ContactMobile + ")<br/>" + data.List[i].Reserve + "</td><td class='r' style='vertical-align:middle'><a href='tbldetails.html?PageFlag=1&OrderId=" + data.List[i].OrderId + "' class='btn2'>查看</a></td></tr>";
                            }*/
                        }
                        $("#tbllist").html(str);
                    }
                    else {
                        if (data.Url != "") {
                            updateTip(data.Msg, true, "URL", data.Url);
                        }
                        else {
                            $("#Total").text("0");
                            $(".tips")[0].style.display = "";
                            $("#msgtip").text(data.Msg);
                        }
                    }
                }
            });
        }
        function getHandleTypes(flag) {
            var datas = "&flag=" + flag;
            var url = "CommonPage.aspx?opration=getHandleType" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    if (data.Success) {
                        $("#Seated").text(data.Seated);
                        $("#OpenTable").text(data.OpenTable);
                        $("#CheckOut").text(data.CheckOut);
                        $("#Scheduled").text(data.Scheduled);
                        $("#Clear").text(data.Clear); 
                    }
                    else {
                        if (data.Url != "") {
                            updateTip(data.Msg, true, "URL", data.Url);
                        }
                    }
                }
            });
        }
    </script>
</head>

<body>
    <div class="wrapall">
        <table class="topbar">
            <tr>
                <td class="l"><a class="goback">返回</a></td>
                <td class="c" id="H_Name"></td>
                <td class="r" >
                    <ul class="flexy-menu">
                        <li id="lilist">
                        </li>
                    </ul>
                </td>
            </tr>
        </table>
        <p class="textinfo">共有<b id="Total">0</b>桌。</p>
        <div class="tab12">
		<table>
			<tr>
				<td class="menulink"><a href="#" onclick="getOrderLists('');"><span id="tabOne">今天</span><b>∨</b></a>
				<ul>
					<li class="cur"><a href="#" onclick="getOrderList('Today');">今天<i id="Today"></i></a></li>
					<li><a href="#" onclick="getOrderList('Tomorrow');">明天<i id="Tomorrow"></i></a></li>
					<li><a href="#" onclick="getOrderList('Postnatal');">后天<i id="Postnatal"></i></a></li>
					<li><a href="#" onclick="getOrderList('OtherTime');">其他时间</a></li>
				</ul></td>
				<td class="menulink"><a href="#" onclick="getTableTypes('');"><span id="tabTwo">类型</span><b>∨</b></a>
				<ul>
					<li class="cur"><a href="#" onclick="getTableType('All');">全部<i id="All">(0)</i></a></li>
					<li><a href="#" onclick="getTableType('Rooms');">包厢<i id="Rooms">(0)</i></a></li>
					<li><a href="#" onclick="getTableType('Hall');">大厅<i id="Hall">(0)</i></a></li>
					<li><a href="#" onclick="getTableType('AddTable');">加台<i id="AddTable">(0)</i></a></li>
				</ul>
				</td>
				<td class="menulink"><a href="#" onclick="getHandleTypes('');"><span id="tabThree">操作</span><b>∨</b></a>
				<ul>
				    <!--<li class="cur"><a href="#" onclick="getHandleType('Seated');">就坐<i id="Seated">(0)</i></a></li>
				        <li><a href="#" onclick="getHandleType('OpenTable');">开台<i id="OpenTable">(0)</i></a></li>
				        <li><a href="#" onclick="getHandleType('CheckOut');">结账<i id="CheckOut">(0)</i></a></li>-->
				    <li  class="cur"><a href="#" onclick="getHandleType('OpenTable');">欢迎光临<i id="OpenTable">(0)</i></a></li>
                    <li><a href="#" onclick="getHandleType('Scheduled');">已被预订<i id="Scheduled">(0)</i></a></li>
                    <li ><a href="#" onclick="getHandleType('Seated');">正在点菜<i id="Seated">(0)</i></a></li> 
				    <li><a href="#" onclick="getHandleType('CheckOut');">正在用餐<i id="CheckOut">(0)</i></a></li>
				    <li><a href="#" onclick="getHandleType('Clear');">正在清理<i id="Clear">(0)</i></a></li> 

				</ul></td>
			</tr>
		</table>
	</div>
        <table class="tbllist" id="tbllist">
        </table>
        <span class="tips" style="display: none;"><i></i><b id="msgtip"></b>

        </span>
        <br />
    </div>
    <div id="dialog" title="提示信息" style="text-align:center; vertical-align: middle;">
        <p class="dialogTip"></p>
    </div>
</body>
</html>
